<script setup>
	import {ref} from 'vue'
	import {useCountStore} from '@/store/count.js';
	const countStore=useCountStore()
	
	let n=ref(1)
	
	function add() {
		countStore.add(n.value)
	}
	function sub() {
		countStore.sub(n.value)
	}
	
</script>

<template>
	<div>
		<h2>当前求和为{{countStore.sum}}</h2>
		<select v-model.number="n">    <!--转为数字类型而非字符串-->
			<option value="1">1</option>
			<option value="2">2</option>
			<option value="3">3</option>
		</select><br>
		<button @click="add">加</button>
		<button @click="sub">减</button>
	</div>
</template>

<style scoped>

</style>